/*******************************************************************************
 * Copyright (c) 2008, 2009 Tapestry IDE Developers
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Tapestry IDE Developers - initial API and implementation
 *******************************************************************************/
package com.googlecode.tapestry.ide.core.model;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;

/**
 * Common protocol for all elements provided by the model.
 */
public interface IModelElement extends IAdaptable {

	/** Used for child-less model elements. */
	IModelElement[] NO_CHILDREN = new IModelElement[0];

	/**
	 * Returns the element directly containing this element, or
	 * <code>null</code> if this element has no parent.
	 * 
	 * @return the parent element, or <code>null</code> if this element has no
	 *         parent
	 */
	IModelElement getElementParent();

	/**
	 * Returns an array with all children of this element.
	 * 
	 * @return an array with the children elements
	 */
	IModelElement[] getElementChildren();

	/**
	 * Returns the name of this element.
	 * 
	 * @return the element's name
	 */
	String getElementName();

	/**
	 * Accepts the given visitor. The visitor's <code>visit</code> method is
	 * called with this model element. If the visitor returns <code>true</code>,
	 * this method visits this element's members.
	 * 
	 * @param visitor
	 *            the visitor
	 * @param monitor
	 *            the progress monitor used to give feedback on progress and to
	 *            check for cancellation
	 * 
	 * @see IModelElementVisitor#visit(IModelElement)
	 */
	void accept(IModelElementVisitor visitor, IProgressMonitor monitor);

}
